<?php


namespace App\Controller\Cooperative;


use App\Controller\AbstractController;
use App\Model\Task;
use App\Request\Cooperative\TaskExecArbitrationRequest;
use App\Request\Cooperative\TaskExecIndexRequest;
use App\Request\Cooperative\TaskExecUrgeRequest;
use App\Service\Cooperative\TaskExecService;
use Hyperf\Di\Annotation\Inject;

class TaskExecController extends AbstractController
{

    /**
     * @Inject()
     * @var TaskExecService
     */
    protected $taskExecService;

    public function index(TaskExecIndexRequest $request)
    {
        $validated = $request->validated();
        $index = $this->taskExecService->index($validated);
        return $this->response->success($index);
    }

    public function employerWin(int $taskExecId, TaskExecArbitrationRequest $request)
    {
        $validated = $request->validated();
        $this->taskExecService->employerWin($taskExecId, $validated);
        return $this->response->success();
    }

    public function userWin(int $taskExecId, TaskExecArbitrationRequest $request)
    {
        $validated = $request->validated();
        $this->taskExecService->userWin($taskExecId, $validated);
        return $this->response->success();
    }

    public function urgeIndex(TaskExecUrgeRequest $request)
    {
        $validated = $request->validated();
        $index = $this->taskExecService->urgeIndex($validated);
        return $this->response->success($index);
    }
}